'''
https://leetcode.cn/problems/range-sum-query-immutable/
'''

from typing import List


class NumArray:

    def __init__(self, nums: List[int]):
        n = len(nums)
        self.pre_sum = [0] * (n + 1)
        for i in range(n):
            self.pre_sum[i + 1] = self.pre_sum[i] + nums[i]

    def sumRange(self, left: int, right: int) -> int:
        return self.pre_sum[right] - self.pre_sum[left - 1]

# Your NumArray object will be instantiated and called as such:
nums = [-2,0,3,-5,2,-1]
obj = NumArray(nums)
param_1 = obj.sumRange(2,3)
print(param_1)

